﻿/****************************************************************
  Author:  Ievgenii Nazaruk, ievgenii.nazaruk@gmail.com 
 License:  Microsoft Public License (Ms-PL)
          ( http://www.opensource.org/licenses/ms-pl.html or
            http://www.microsoft.com/opensource/licenses.mspx )
*****************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TableParsers
{
    public enum ClassType 
    {
        Group,
        Club,
        Grammar,
        Writing,
        Reading,
        Conversation,
        FirstClass,
        ProgressFollowup,
        Unknown
    }

    public enum ClassKind
    {
        Group,
        Club,
        Workshop,
        Management,
        Unknown
    }
    
    public class ClassNameException : Exception
    {
        String RawClassName = null;
        public ClassNameException(string originalValue)
        {
            RawClassName = originalValue;
        }
    }

    [Serializable]
    public class ClassName
    {
        private String m_fullName = null;
        public String FullName
        {
            get
            {
                return m_fullName;
            }
        }

        private String m_name = null;
        public String Name
        {
            get
            {
                return m_name;
            }
        }

        private ClassType m_type = ClassType.Unknown;
        public ClassType Type
        {
            get
            {
                return m_type;
            }

            private set
            {
                if (value == ClassType.Group)
                {
                    m_kind = ClassKind.Group;
                }
                else if (value == ClassType.Club)
                {
                    m_kind = ClassKind.Club;
                }
                else if(value == ClassType.Grammar ||
                        value == ClassType.Reading ||
                        value == ClassType.Writing ||
                        value == ClassType.Conversation)
                {
                    m_kind = ClassKind.Workshop;
                }
                else if(value == ClassType.ProgressFollowup ||
                        value == ClassType.FirstClass)
                {
                    m_kind = ClassKind.Management;
                }
                else
                {
                    m_kind = ClassKind.Unknown;
                }

                m_type = value;
            }
        }

        private ClassKind m_kind = ClassKind.Unknown;
        public ClassKind Kind
        {
            get
            {
                return m_kind;
            }
        }

        public ClassName(String fullName, String name, ClassType type)
        {
            Type = type;
            m_fullName = fullName;
            m_name = name;            
        }       

        public override string ToString()
        {
            switch (Kind)
            {
                case ClassKind.Club:
                    {
                        return "Club - "+Name;
                    }                    
                case ClassKind.Group:
                    {
                        return "Group Class (" + Name + ") ";
                    }                    
                case ClassKind.Workshop:
                    {
                        return Name+" Workshop";
                    }
                case ClassKind.Management:
                    {
                        return Name;
                    }
            }

            return FullName;
        }

        
    }
}
